/* Pause Function created by Brian New 24/03/02. */

#ifndef timerace
#define timerace

#include <windows.h>					// For 'GetTickCount()'.


void Pause(unsigned int seconds)		// Specify number of seconds to elapse.
{
	signed int start = GetTickCount();
	while (((GetTickCount() - start)/1000) < seconds) {}	// Loops until seconds elapsed.
}


/* #########################################################################################
To use the LoopPause() functions. This function is designed to allow you to carry out a 
section of code for a desired number of seconds.

Step (1): Call 'LoopPause(int)' 
		  
		  In the parameters, specify the duration of looping in seconds, e.g. LoopPause(5); 

Step (2): Surround the code to be looped for desised time with a 'while() {}' Structure.

		  In the parameters of the while() structure, call the LoopPause(void) Function.

		  e.g.

		  LoopPause(5);          // This statement explained in Step(1).

		  while(LoopPause()) 
		  {
				YOUR CODE HERE
				YOUR CODE HERE
				      ETC
		  }

LoopPause Functions created by Brian New, 24/03/02.
########################################################################################### */

unsigned int LpP_StartTime;				// Global variables, used with LoopPause.
unsigned int LpP_Duration;
void LoopPause(int duration_in_seconds)
{
	LpP_StartTime = GetTickCount();		// Establish starting time.
	LpP_Duration = duration_in_seconds;	// Assign the duration to global variable.
}	

bool LoopPause(void)
{
	if (LpP_Duration > ((GetTickCount() - LpP_StartTime)/1000)) 
		return 1;	// Do not break loop, time is not up yet.
		
		// Fall through.
		return 0;	// If time is up, return FALSE, so that WHILE loop is broken.
}

#endif